// 仓库管理系统数据模型

class Item {
    constructor(id, name, description, price, stock) {
        this.id = id;
        this.name = name;
        this.description = description;
        this.price = price;
        this.stock = stock;
    }
}

class Warehouse {
    constructor() {
        this.items = [];
    }

    addItem(item) {
        this.items.push(item);
    }

    removeItem(id) {
        this.items = this.items.filter(item => item.id !== id);
    }

    updateItem(id, updatedItem) {
        const index = this.items.findIndex(item => item.id === id);
        if (index !== -1) {
            this.items[index] = updatedItem;
        }
    }

    getItemById(id) {
        return this.items.find(item => item.id === id);
    }

    getAllItems() {
        return this.items;
    }
}

export { Item, Warehouse };